package com.company.gxcpc2018;

import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Gxcpc10 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            BigInteger[] array = Stream.generate(sc::nextBigInteger).limit(n).toArray(BigInteger[]::new);
            int num = Arrays.stream(array).reduce(BigInteger::gcd).get().intValue();
            System.out.println(num * n);
        }
    }
}
